<?php
/**
 * categories_tabs.php module
 *
 * @package templateSystem
 * @copyright Copyright 2003-2006 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: categories_tabs.php 3018 2006-02-12 21:04:04Z wilt $
 */
if (!defined('IS_ADMIN_FLAG')) {
  die('Illegal Access');
}
$order_by = " order by c.sort_order,cd.categories_name ";

$categories_sql = "select c.categories_id, c.parent_id, c.categories_image, cd.categories_name from " .
TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd
                          where c.categories_id=cd.categories_id and cd.language_id='" . (int)$_SESSION['languages_id'] . "' and c.categories_status='1'" .
$order_by;
$categories_r = $db->Execute($categories_sql);
$c_array = array();
while (!$categories_r->EOF) {
	if (!isset($c_array[$categories_r->fields['parent_id']])){
		$c_array[$categories_r->fields['parent_id']] = array(array('categories_id'=>$categories_r->fields['categories_id'],'categories_name'=>$categories_r->fields['categories_name'],'categories_image'=>$categories_r->fields['categories_image']));
	}else{
		$c_array[$categories_r->fields['parent_id']][] = array('categories_id'=>$categories_r->fields['categories_id'],'categories_name'=>$categories_r->fields['categories_name'],'categories_image'=>$categories_r->fields['categories_image']);
	}
	$categories_r->MoveNext();
}
?>